﻿<UserControl x:Class="Caffeine.Examples.Contacts.View.AddressView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:presentationCore="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
             xmlns:contactViews="clr-namespace:Caffeine.Examples.Contacts.View">
    <Grid HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <!---Street Address-->
        <TextBlock Text="Street Address" HorizontalAlignment="Right" Margin="2" VerticalAlignment="Bottom" />
        <WrapPanel Grid.Column="1" Width="235">
            <TextBox DataContext="{Binding StreetAddress}" 
                     Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" 
                     Width="200" 
                     MaxLength="200" 
                     HorizontalAlignment="Left" 
                     Margin="2"
                     Style="{DynamicResource ValidatedTextBox}" />
            <TextBlock Style="{DynamicResource ChangeNotificationText}" 
                       DataContext="{Binding StreetAddress}" />
        </WrapPanel>

        <!--Zip Code-->
        <TextBlock Grid.Row="1" Text="Zip Code" HorizontalAlignment="Right" Margin="2" VerticalAlignment="Bottom" />
        <WrapPanel Grid.Row="1" Grid.Column="1">
            <TextBox DataContext="{Binding ZipCode}"
                     Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" 
                     Width="75" 
                     MaxLength="5" 
                     HorizontalAlignment="Left" 
                     Margin="2"
                     Style="{DynamicResource ValidatedTextBox}" />
            <TextBlock Style="{DynamicResource ChangeNotificationText}" 
                       DataContext="{Binding ZipCode}" />
        </WrapPanel>
        
        <WrapPanel Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right">
            <WrapPanel.Resources>
                <Style TargetType="Button">
                    <Setter Property="Margin" Value="10,0,0,0" />
                </Style>
            </WrapPanel.Resources>
            <Button ToolTip="Save address" 
                    Style="{StaticResource SaveButton}"  
                    Command="{Binding Save}" 
                    Visibility="{Binding ShowCommitChangesCommand, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Button ToolTip="Undo Changes" 
                    Command="{Binding UndoChanges}" 
                    Style="{StaticResource UndoButton}"  
                    Margin="10,0,0,0"
                    Visibility="{Binding ShowUndoChangesCommand, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Button ToolTip="Remove" 
                    Command="{Binding RemoveFromContact}" 
                    Style="{StaticResource RemoveButton}"  
                    Margin="10,0,0,0"
                    Visibility="{Binding ShowRemoveFromContactCommand, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Button ToolTip="Cancel adding address" 
                    Style="{StaticResource CancelButton}"  
                    Command="{Binding CancelAddToContact}" 
                    Margin="10,0,0,0"
                    Visibility="{Binding ShowCancelAddToContactCommand, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Button ToolTip="Permanently remove"
                    Style="{StaticResource SaveButton}"
                    Visibility="{Binding ShowCommitRemoveFromContactCommand, Converter={StaticResource BooleanToVisibilityConverter}}"
                    Margin="10,0,0,0"
                    Command="{Binding RemoveFromContactCommit}" 
                    CommandParameter="{Binding}" />
            <Button ToolTip="Undo remove" 
                    Style="{StaticResource UndoButton}"  
                    Visibility="{Binding ShowUndoRemoveFromContactCommand, Converter={StaticResource BooleanToVisibilityConverter}}"
                    Margin="10,0,0,0"
                    Command="{Binding UndoRemoveFromContact}" 
                    CommandParameter="{Binding}" />
        </WrapPanel>
    </Grid>
</UserControl>
